﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace randlib.core
{
    public class RandomUnity
    {

        uint seed;

        public RandomUnity(uint seed = 0x6E624EB7u)
        {
            this.seed = seed;

        }
        uint NextState()
        {
           
            //修改随机数实现和Unity一致
            var state = seed;

            state ^= state << 13;
            state ^= state >> 17;
            state ^= state << 5;
            seed = state;

            return state;
        }
   
        public int NextInt()
        {
            return (int)NextState() ^ -2147483648;
        }

    }
}
